<?php

namespace app\test\controller;
use think\Request;
/**
 * 获取参数的方式方法
 */
class Test
{
	
	public function index($id, $name)
	{
		// return 'text text index'.$id;
		var_dump($_POST);
		return 'text text index-- id = '.$id.'---name = '.$name;
	}

	public function demo()
	{
		// $params = Request::instance()->param();
		// $id = Request::instance()->param('id');
		// $name = Request::instance()->param('name');
		// $age = Request::instance()->param('age');

		// $id = Request::instance()->route();  // 路径里面的
		// $name = Request::instance()->get(); // ?后面的
		// $age = Request::instance()->post(); // post 传递的
		
		// 助手函数
		$params = input("param.");
		$id = input("param.id");
		// $name = input("param.name");
		// $age = input("param.age");

		// $id   = input("route.id");// 无法获取
		// $id   = input("get.id");// 无法获取
		// $id   = input("post.id");// 无法获取
		$name = input("get.name");
		$age  = input("post.age");


		var_dump($params, $id, $name, $age);
		// return 'text text index-- id = '.$id.'---name = '.$name;
	}

	// 依赖注入
	public function demo1(Request $request)
	{
		$params = $request->param();
		$id = $request->param('id');
		$name = $request->param('name');
		$age = $request->param('age');

		$id = $request->route();
		$name = $request->get();
		$age = $request->post();
		var_dump($params, $id, $name, $age);
	}
}